package com.atguigu.tingshu.account.api;

import com.atguigu.tingshu.account.service.RechargeInfoService;
import com.atguigu.tingshu.common.login.GuiLogin;
import com.atguigu.tingshu.common.result.Result;
import com.atguigu.tingshu.model.account.RechargeInfo;
import com.atguigu.tingshu.vo.account.RechargeInfoVo;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.web.bind.annotation.*;

@Tag(name = "充值管理")
@RestController
@RequestMapping("api/account/rechargeInfo")
@SuppressWarnings({"unchecked", "rawtypes"})
public class RechargeInfoApiController {


	@Autowired
	private RechargeInfoService rechargeInfoService;

	/**
	 * 提交充值订单
	 * @param rechargeInfoVo
	 * @return
	 */
	@GuiLogin
	@PostMapping("/submitRecharge")
	public Result submitRecharge (@RequestBody RechargeInfoVo rechargeInfoVo){
		return Result.ok(rechargeInfoService.submitRecharge(rechargeInfoVo));
	}

	/**
	 * 取消充值订单
	 * @param orderNo
	 * @return
	 */
	@GuiLogin
	@GetMapping("/cancleRechargeInfo/{orderNo}")
	public Result cancleRechargeInfo(@PathVariable(value = "orderNo")String orderNo){
		rechargeInfoService.cancleRechargeInfo(orderNo);
		return Result.ok();
	}


	/**
	 * 获取支付地址
	 * @param orderNo
	 * @return
	 */
	@GetMapping("/getRechargePayInfo/{orderNo}")
	public Result getRechargePayInfo (@PathVariable(value = "orderNo")String orderNo){
		return Result.ok(rechargeInfoService.getRechargePayInfo(orderNo));
	}
}

